package com.jiandan.aspect;

import java.util.Map;
import android.os.SystemClock;
/**
 * @author : xfhy
 * Create time : 2020/8/19 10:53 PM
 * Description : 快速点击 工具类
 */
public class FastClickUtil {


    private static Map<String, Long> clickMap = new MaxSizeHashMap<>(10);

    public static boolean isFastDoubleClick(String key, long clickLimit) {
        //System.out.println("isFastDoubleClick "+ key + "  " + clickLimit);
        long currentTime = SystemClock.elapsedRealtime();
        if (clickMap.containsKey(key)) {
            long lastClickTime = clickMap.get(key);
            if (currentTime - lastClickTime < clickLimit) {
                return true;
            }
        }
        clickMap.put(key, currentTime);
        return false;
    }

}
